package kk.learn.bigdata.jedisclusterdemo;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

/**
 * <p>
 *
 * </p>
 *
 * @author KK
 * @since 2021-02-04
 */
public class JedisClusterDemo {
    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
        jedisClusterNode.add(new HostAndPort("172.16.225.121", 7001));
        jedisClusterNode.add(new HostAndPort("172.16.225.121", 7002));
        jedisClusterNode.add(new HostAndPort("172.16.225.121", 7003));
        jedisClusterNode.add(new HostAndPort("172.16.225.121", 7004));
        jedisClusterNode.add(new HostAndPort("172.16.225.121", 7005));
        jedisClusterNode.add(new HostAndPort("172.16.225.121", 7006));
        JedisCluster jcd = new JedisCluster(jedisClusterNode, config);

        // 设置数据
        jcd.set("name:001", "zhangfei");
        // 获取数据
        String value = jcd.get("name:001");

        System.out.println("设置值的返回结果：" + value);
    }

}
